/*
 * ========================================================
 * Copyright(c) 2014 杭州龙骞科技-版权所有
 * ========================================================
 * 本软件由杭州龙骞科技所有, 未经书面许可, 任何单位和个人不得以
 * 任何形式复制代码的部分或全部, 并以任何形式传播。
 * 公司网址
 * http://www.hzdracom.com/
 * ========================================================
 */
package com.shwread.httpsdk.http.face;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import logic.bean.BannerInfo;
import logic.constants.AppConfig;
import logic.constants.Const;

import org.json.JSONObject;

import android.content.Context;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.shwread.httpsdk.constant.ResultCode;
import com.shwread.httpsdk.http.base.AbstractHttpPostDracom;
import com.shwread.httpsdk.http.callback.ActionListener;


/**
 * @Project： Lqyd_Android
 * @Title：QrySpecialInfoListAction
 * @Description：精品首页Banner位书籍
 * @Author：wayne
 * @Date：2014年8月15日上午11:22:48
 */
public class QrySpecialInfoListAction
        extends
        AbstractHttpPostDracom
{
	
	/**
	 * <p>
	 * Title:
	 * </p>
	 * <p>
	 * Description:
	 * </p>
	 * 
	 * @param context
	 * @param action
	 * @param actionListener
	 */
	public QrySpecialInfoListAction(Context context, ActionListener actionListener) {
		super(context, "qrySpecialInfoList.do", actionListener);
	}
	
	@Override
	public void getParameter(HashMap<String, String> parameter_map) {
		parameter_map.put("enterpriseId", AppConfig.getEnterpriseId());
		parameter_map.put("account", Const.phone_number);
		parameter_map.put("timeStamp", String.valueOf(timeStamp));
		parameter_map.put("cid", cid(Const.phone_number + Const.ACCOUNTTYPE + Const.CLIENTTYPE + timeStamp + AppConfig.getEnterpriseId()));
	}
	
	@Override
	public void doResponseXml(String xml) {
		println(xml);
		int result = -1;
		try
		{
			JSONObject jsonObject = new JSONObject(xml);
			result = jsonObject.getInt("resultCode");
			if (result == 1000)
			{
				List<BannerInfo> banners = new ArrayList<BannerInfo>();
				Gson gson = new Gson();
				banners = gson.fromJson(jsonObject.getString("returnObject"), new TypeToken<List<BannerInfo>>()
				{
				}.getType());
				
				listener.OK(banners);
			}
			else
			{
				listener.ERROR(result, ResultCode.getResultText(result));
			}
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
	}
	
	@Override
	protected void doRequestHeader(HashMap<String, String> header_map) {
		
	}
	
	@Override
	public void dispose() {
		
	}
	
}
